package application;

import java.util.ArrayList;
import java.lang.Character;

public class StrStack {

        ArrayList a;
        int currentItem;

        public StrStack() {
            a = new ArrayList();
            currentItem = 0;
        }

        public void push(Object o) {
            a.add(o);
            currentItem++;
        }

        public Object pop() {
            Object result = a.get(--currentItem);
            a.remove(currentItem);
            return result;
        }

        public void showStack() {
            System.out.println(a.toString());
        }

        public boolean isEmpty() {
            if (currentItem == 0) {
                return false;
            }
            return true;
        }

        public int getCurrentItem() {
            return currentItem;
        }
    

    public Object getLast() {
        return (currentItem < 0 ? a.get(currentItem) : "");
    }
    public String devaststeStack(){
        String result ="";
        for (int i = currentItem-1; i > 0; i--) {
            result += a.get(i);
        }
        return result;
    }
}
